package com.example.administrator.videotest2.util.Tab;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.videotest2.R;
import com.example.administrator.videotest2.entity.VideoCover;

import java.util.List;

public class VideoAdapter extends ArrayAdapter<VideoCover> {

    private int resourceId;
    public VideoAdapter(Context context, int textViewResourceId, List<VideoCover> objects) {
        super(context,  textViewResourceId, objects);
        resourceId=textViewResourceId;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        VideoCover cover=getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        ImageView img=view.findViewById(R.id.img);
        TextView title=view.findViewById(R.id.v_name);
        TextView toup=view.findViewById(R.id.toup);
        toup.setText(cover.getToup());
        Glide.with(getContext()).load(cover.getImage()).centerCrop().into(img);
        title.setText(cover.getTitle());
        return view;
    }
}